// HSS.Logging.Management.SqlExecutionException.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       SqlExecutionException.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
namespace HSS.Logging.Management
{
	#region Using Directives
	using System;
	using System.Data.SqlClient;
	using System.Runtime.Serialization;
	#endregion

	/// <summary>
	/// Defines a class for SQL execution exceptions in the HSS.Logging.Management namespace.
	/// </summary>
	[Serializable]
	public sealed class SqlExecutionException : SystemException
	{
		// Fields
		private string _commands;
		private string _database;
		private string _server;
		private SqlException _sqlException;
		private string _sqlFile;

		// Methods

		/// <summary>
		/// ctor
		/// </summary>
		public SqlExecutionException()
		{
		}
		/// <summary>
		/// ctor
		/// </summary>
		/// <param name="message"></param>
		public SqlExecutionException(string message)
			: base(message)
		{
		}
		/// <summary>
		/// ctor
		/// </summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		private SqlExecutionException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
			this._server = info.GetString("_server");
			this._database = info.GetString("_database");
			this._sqlFile = info.GetString("_sqlFile");
			this._commands = info.GetString("_commands");
			this._sqlException = (SqlException)info.GetValue("_sqlException", typeof(SqlException));
		}
		/// <summary>
		/// ctor
		/// </summary>
		/// <param name="message"></param>
		/// <param name="innerException"></param>
		public SqlExecutionException(string message, Exception innerException)
			: base(message, innerException)
		{
		}
		/// <summary>
		/// ctor
		/// </summary>
		/// <param name="message"></param>
		/// <param name="server"></param>
		/// <param name="database"></param>
		/// <param name="sqlFile"></param>
		/// <param name="commands"></param>
		/// <param name="sqlException"></param>
		public SqlExecutionException(string message, string server, string database, string sqlFile, string commands, SqlException sqlException)
			: base(message)
		{
			this._server = server;
			this._database = database;
			this._sqlFile = sqlFile;
			this._commands = commands;
			this._sqlException = sqlException;
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			base.GetObjectData(info, context);
			info.AddValue("_server", this._server);
			info.AddValue("_database", this._database);
			info.AddValue("_sqlFile", this._sqlFile);
			info.AddValue("_commands", this._commands);
			info.AddValue("_sqlException", this._sqlException);
		}

		/// <summary>
		/// 
		/// </summary>
		public string Commands
		{
			get
			{
				return this._commands;
			}
		}
		/// <summary>
		/// 
		/// </summary>
		public string Database
		{
			get
			{
				return this._database;
			}
		}
		/// <summary>
		/// 
		/// </summary>
		public SqlException Exception
		{
			get
			{
				return this._sqlException;
			}
		}
		/// <summary>
		/// 
		/// </summary>
		public string Server
		{
			get
			{
				return this._server;
			}
		}
		/// <summary>
		/// 
		/// </summary>
		public string SqlFile
		{
			get
			{
				return this._sqlFile;
			}
		}
	}
}